import { UserProfilesAIP } from "../../request/api";

export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: '张三',
            coin: 0,
            headImg: require('../../assets/img/service.848ec511.png')
        },
        cartTotal: 0

    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal;
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: '张三',
                coin: 0,
                headImg: require('../../assets/img/service.848ec511.png')
            },
                state.cartTotal = 0;
        }
    },
    actions: {
        async asyncChangeUserInfo({ commit }) {
            let res = await UserProfilesAIP();
            commit("changeUserInfo", res.data)

        }
    }

}